# 默认参数函数
def defaultParamFunc(prompt, retries=4, reminder="Please try again!"):
    while True:
        ok = input(prompt)
        if ok in ('y', 'ye', 'yes'):
            return True
        if ok in ('n', 'no'):
            return False
        retries = retries - 1
        if retries < 0:
            raise ValueError('invalid user response')
        print(reminder)


# 可变参数
def variableParamFunc(kind, *arguments, **keywords):
    print("friend : ", kind, ";")
    print("-" * 40)
    for arg in arguments:
        print(arg)
    print("-" * 40)
    for kw in keywords:
        print(kw, ":", keywords[kw])


def invoke_var():
    variableParamFunc("xiaoming",
                      "hello xiaoming", "nice to meet you",
                      mother="xiaoma",
                      father="xiaoba",
                      son="see you")


# 关键字参数
def keyParamFunc(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
    print("-- This key_fun wouldn't", action, end=' ')
    print("if you put", voltage, "volts through it.")
    print("-- Lovely plumage, the", type)
    print("-- It's", state, "!")
    print()


def invoke_key():
    keyParamFunc(1000)  # 1 positional argument
    keyParamFunc(voltage=1000)  # 1 keyword argument
    keyParamFunc(voltage=1000000, action='VOOOOOM')  # 2 keyword arguments
    keyParamFunc(action='VOOOOOM', voltage=1000000)  # 2 keyword arguments
    keyParamFunc('a million', 'bereft of life', 'jump')  # 3 positional arguments
    keyParamFunc('a thousand', state='pushing up the daisies')  # 1 positional, 1 keyword
